import request from "@/utils/request";
import qs from "qs";

// 查询数据库信息列表
export function queryPageList(query) {
  return request({
    url: "/datascan/b/dbinfo/queryPageList",
    method: "get",
    params: query,
  });
}

// 查询数据库信息列表
export function queryList(query) {
  return request({
    url: "/datascan/b/dbinfo/queryList",
    method: "get",
    params: query,
  });
}

// 新增数据库信息
export function add(data, isFormdata) {
  return request({
    url: "/datascan/b/dbinfo/add",
    method: "post",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8;multipart/form-data;",
    },
    data: isFormdata ? data : qs.stringify(data),
  });
}

// 编辑数据库信息
export function update(data, isFormdata) {
  return request({
    url: "/datascan/b/dbinfo/update",
    method: "post",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8;multipart/form-data;",
    },
    data: isFormdata ? data : qs.stringify(data),
  });
}

//修改密码

export function updatePassword(data) {
  return request({
    url: "/datascan/b/dbinfo/updatePassword",
    method: "post",
    data,
  });
}

//批量修改密码
export function batchUpdatePassword(data) {
  return request({
    url: "/datascan/b/dbinfo/batchUpdatePassword",
    method: "post",
    data,
  });
}

// 查询数据库信息详细
export function query(query) {
  return request({
    url: "/datascan/b/dbinfo/query",
    params: query,
  });
}

// 删除数据库信息
export function del(data) {
  return request({
    url: "/datascan/b/dbinfo/delete",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
    },
    method: "post",
    data: qs.stringify(data),
  });
}

// 删除数据库信息
export function scan(data) {
  return request({
    url: "/datascan/b/dbscanresult/scan",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
    },
    method: "post",
    data: qs.stringify(data),
  });
}

// 测试数据源连通性
export function testConnection(query) {
  return request({
    url: "/datascan/b/dbinfo/testConnection",
    params: query,
  });
}

// 更新分级分类
export function updateTypeAndLevel(data) {
  return request({
    url: "/datascan/b/dbscanresult/updateTypeAndLevel",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
    },
    method: "post",
    timeout: 10 * 60 * 1000,
    data: qs.stringify(data),
  });
}

// 负责人用户列表
export function queryUserList(query) {
  return request({
    url: "/datascan/b/dbinfo/queryUserList",
    method: "get",
    params: query,
  });
}

// 部门列表
export function selectAllDept(query) {
  return request({
    url: "/datascan/b/dbinfo/selectAllDept",
    method: "get",
    params: query,
  });
}

export function queryBusinessList(params) {
  return request({
    url: "/datascan/b/dbinfo/queryOperationSystem",
    method: "get",
    params,
  });
}

// // 更新分级分类
// export function updateTypeAndLevel(data) {
//   return request({
//     url: '/datascan/b/dbinfo/queryUserList',
//     headers: {
//       'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
//     },
//     method: 'post',
//     timeout: 10 * 60 * 1000,
//     data: qs.stringify(data)
//   })
// }
